package com.hytc.mymall.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hytc.mymall.R;
import com.hytc.mymall.bean.MineInfoBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by allkiss on 2016/12/9
 */
public class MineAdapter extends BaseAdapter {

    Context context;
    List<MineInfoBean> list;

    public MineAdapter(final Context context, final List<MineInfoBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int n, View view, final ViewGroup viewGroup) {
        ViewHolder viewHolder=null;
        if (view == null) {
            view = View.inflate(this.context, R.layout.item_mine, null);
            viewHolder=new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder= (ViewHolder) view.getTag();
        }
        if(n==list.size()-1){
            viewHolder.rlItemMineDate.setVisibility(View.VISIBLE);
            viewHolder.ivItemMineArrow.setVisibility(View.VISIBLE);
            viewHolder.tvItemMineCount.setText(list.get(n).count);
            viewHolder.tvItemMineTitle.setText(list.get(n).titile);
            viewHolder.tvItemMineDate.setText("201-9-2");
        }else {
            viewHolder.rlItemMineDate.setVisibility(View.GONE);
            viewHolder.ivItemMineArrow.setVisibility(View.GONE);
        }
        return view;
    }

    static class ViewHolder {
        @BindView(R.id.tv_item_mine_date)
        TextView tvItemMineDate;
        @BindView(R.id.rl_item_mine_date)
        RelativeLayout rlItemMineDate;
        @BindView(R.id.tv_item_mine_title)
        TextView tvItemMineTitle;
        @BindView(R.id.tv_item_mine_count)
        TextView tvItemMineCount;
        @BindView(R.id.iv_item_mine_arrow)
        ImageView ivItemMineArrow;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
